package lanqiao._01基础练习;

import java.util.Scanner;

/**
 * @author 挚爱之夕
 * @version 1.0
 * @implSpec lanqiao._基础练习
 * @since 2022 - 10 - 26 - 23:43
 */
public class _04十六进制转十进制 {
}

class Main4{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long val = 0;
        String s = sc.nextLine();
        int len = s.length();
        for(int i = len - 1; i >= 0; i--){
            char c = s.charAt(i);
            if(c <= '9'){
                if(i == len - 1){
                    val += c - '0';
                    continue;
                }
                val += (c - '0') * Math.pow(16, len - i - 1);
            }else{
                if(i == len - 1){
                    val += c - 'A' + 10;
                    continue;
                }
                val += (c - 'A' + 10) * Math.pow(16, len - i - 1);
            }
        }
        System.out.println(val);
    }
}